Add opt-in sidekiq extension for annotating delayed classes#115
Add opt-in sidekiq extension for annotating delayed classes#115bf4 wants to merge 1 commit intobasecamp:masterfrom
Conversation
Even if no one wants to use the extension as is, it makes a good example of how one may do it.
Usage: in config/initializers/sidekiq.rb
```ruby
Marginalia::SidekiqInstrumentation.enable!(annotate_delayed_class_extension: true)
```
optionally customize the `marginalia_annotate_perform` method, for example
```ruby
Sidekiq::Extensions::DelayedClass.class_eval do
def marginalia_annotate_perform(target, method_name, args)
Rollbar.scope!(target, method_name, *args)
"#{target}.#{method_name}"
end
end
```
|
@sj26 any thoughts on this? |
|
Sorry @bf4, I'm not sure what this is doing? Is it reaching more deeply into Sidekiq integration to craft better annotations? I really only jumped in to get automated testing working, and update marginalia to modern rails versions, not to introduce new features. 😅 |
| # NOTE: Prefer redefining perform so that YAML is only parsed once. | ||
| # Adding a Marginalia::Comment.components would incur an extra parsing on every query | ||
| # in a delayed class | ||
| def perform(yml) |
There was a problem hiding this comment.
@bf4 Do you have a shareable sample or example Yaml block that would be used as the input here? Is this a Sidekiq thing that has serialized values for target, method_name, and args?
| if annotate_delayed_class_extension | ||
| Sidekiq::Extensions::DelayedClass.class_eval do | ||
| # NOTE: Prefer redefining perform so that YAML is only parsed once. | ||
| # Adding a Marginalia::Comment.components would incur an extra parsing on every query |
There was a problem hiding this comment.
Did you have an example of an alternative to what was done here, but using the Marginalia::Comment.components mechanism that's documented to show this as a custom component?
I'm hunting for custom component examples.
Even if no one wants to use the extension as is, it makes a good example of how one may do it.
Usage: in config/initializers/sidekiq.rb
optionally customize the
marginalia_annotate_performmethod, for exampleI would have put this in the wiki entry but I couldn't edit that, and I thought this pr may be more productive than an issue or blog post.